import React, { Component } from 'react'

export default class Test extends Component {
  constructor() {
    super()
    console.log('挂载阶段-constructor')
    this.state = {
      msg: 'test1',
    }
  }
  render() {
    console.log('挂载/更新阶段-render')
    return (
      <div>
        Test
        <button
          onClick={() => {
            // this.setState({
            //   msg: 'test2',
            // })
            this.forceUpdate()
          }}
        >
          test-按钮
        </button>
      </div>
    )
  }
  componentDidMount() {
    console.log('挂载阶段-componentDidMount')
  }
  componentDidUpdate() {
    console.log('更新阶段-componentDidUpdate')
  }

  componentWillUnmount() {
    console.log('卸载阶段-componentWillUnmount')
  }
}
